﻿using AutoMapper;
using Gridify.WebAPI.Data;
using Gridify.WebAPI.DTOs;
using Gridify.WebAPI.Extensions; 
using Gridify.WebAPI.Models;
using Microsoft.AspNetCore.Mvc;

namespace Gridify.WebAPI.Controllers;

[ApiController]
[Route("api")]
public class PersonController(
	ApplicationDbContext context,
	IMapper autoMapper, 
	IGridifyMapper<Person> gridifyMapper)
	: ControllerBase
{
	[HttpGet("GetUsers")]
	public Paging<PersonDto> GetUsers([FromQuery] GridifyQuery query)
	{
		return context.Persons.GridifyTo<Person, PersonDto>(
			autoMapper,  
			query,         
			gridifyMapper 
		);
	}
}
